Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed masked flash attention #2589

Merged
merged 4 commits into from
Jun 27, 2024
Merged

Conversation

l-k-11235
Copy link
Contributor

@l-k-11235 l-k-11235 commented May 17, 2024

This PR proposes a fix for the flash attention path in the multi-head attention module.
The flash attention block doesn't support the left padding mask, so we apply it upstream.
Dao-AILab/flash-attention#649

We apply the key_pad_mask to the values contained in the KV-cache at the first step only, for all scenari (standard, flash, sdpa mechanisms).

@vince62s
Copy link
Member

I think it would be great to explain in this PR when and how the key_pad_mask needs to be used, and being clear in the different scenarii (standard, flash, sdpa mechanisms)

@vince62s vince62s merged commit 9991c8d into OpenNMT:master Jun 27, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants